import React, { useRef } from 'react';
import { View, StyleSheet } from 'react-native';
import Video from 'react-native-video';

const MyVideoPlayer = ({ data }: { data: string }) => {
  const videoRef = useRef(null);

  return (
    <View style={styles.container}>
      <Video
        ref={videoRef}
        source={{
          // uri:data,
          uri: 'https://2403a.oss-cn-beijing.aliyuncs.com/2025/09/11/bfac4a493a664d18bf0e1a268f352e78720p.mp4',
        }} // 支持远程URL或本地文件require('./local.mp4')
        style={styles.video}
        controls={true} // 显示默认控制条
        resizeMode="cover"
        onError={error => console.log('Video cannot be loaded', error)}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
  },
  video: {
    width: '100%',
    height: 200,
  },
});

export default MyVideoPlayer;
